const fs = require("fs");

// 封装
function readUtil(func) {
  return (...arg) => {
    return new Promise((resolve, reject) => {
      func(...arg, (err, data) => {
        if (err) reject(err);
        else resolve(data);
      });
    });
  };
}
// 返回一个promise
const mineReadFile = readUtil(fs.readFile);
mineReadFile("./files/a.json").then(
  (val) => {
    console.log(val.toString());
  },
  (err) => {
    console.log(err);
  }
);
